package com.yingdong.sceneserver.net;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class GameUserSession {

	private long lastHeartBeatTimestamp = System.currentTimeMillis();

	private int sessionId;

	private int errHandlerCount;

	private boolean isHandle = true;

	private String ipAddress;

	private boolean isAlive;
	
	private boolean isActive;
	private Map<String, Object> context = new ConcurrentHashMap<String, Object>();

	public boolean isHandle() {
		return isHandle;
	}

	public void setHandle(boolean isHandle) {
		this.isHandle = isHandle;
	}

	public final long getLastHeartBeatTimestamp() {
		return lastHeartBeatTimestamp;
	}

	public final int getSessionId() {
		return sessionId;
	}

	public void setSessionId(int sessionId) {
		this.sessionId = sessionId;
	}

	public final int getCountAfterNoticeErrHandler() {
		return ++errHandlerCount;
	}

	public final Map<String, Object> getContext() {
		return context;
	}

	public GameUserSession(int sessionId, String ip) {
		this.sessionId = sessionId;
		this.ipAddress = ip;
		isAlive=true;
	}

	public Object getObjectByKey(String key) {
		return context.get(key);
	}

	public String getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	public void setLastHeartBeatTimestamp(long lastHeartBeatTimestamp) {
		this.lastHeartBeatTimestamp = lastHeartBeatTimestamp;
	}

	public boolean isAlive() {
		return isAlive;
	}

	public void setAlive(boolean isAlive) {
		this.isAlive = isAlive;
	}

	public boolean isActive() {
		return isActive;
	}

	public void setActive(boolean isActive) {
		this.isActive = isActive;
	}

}
